﻿#define _CRT_SECURE_NO_WARNINGS

#include "UartWriteFile.h"

UartWriteFile::UartWriteFile(void)
{
	
}

void UartWriteFile::WriteToOpenFile(const char * path)
{
	if(fp != NULL)
	{
		cout << "you reopen file!!!" << endl;
		return ;
	}
	
	fp = fopen(path, "w");
	if (fp == NULL)
	{
		cout << "Open file fail." << endl;
	}
}


int UartWriteFile::WriteToDataFile(char* data, int length)
{
	if (data == NULL || length == 0)
	{
		return 0;
	}

	return fwrite(data, 1, length, fp);
}

void UartWriteFile::WriteCloseFile(void)
{
	if(fp == NULL)
	{
		cout << "You reclose file.!!!! " << endl;
		return ;
	}
	
	fclose(fp);
	fp = NULL;
}


FILE* UartWriteFile::WriteGetFIleFp(void)
{
	return this->fp;
}

UartWriteFile::~UartWriteFile()
{

}